package com.augn.controller;

import com.augn.entity.Goods;
import com.augn.entity.Result;
import com.augn.service.IGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author augn
 * @since 2022-09-22
 */
@RestController
@RequestMapping("/goods")
public class GoodsController {

    @Autowired
    private IGoodsService service;

    @PostMapping("/insertOne")
    public Result<?> insertOneGoods(@RequestBody Goods goods) {
        return service.insertOneGoods(goods);
    }

    @DeleteMapping("/deleteOne/{id}")
    public Result<?> deleteOneGoods(@PathVariable Integer id) {
        return service.deleteOneGoods(id);
    }

    @PutMapping("/updateOne")
    public Result<?> updateOneGoods(@RequestBody Goods goods) {
        return service.updateOneGoods(goods);
    }

    @GetMapping("/getOne/{id}")
    public Result<?> getOneGoods(@PathVariable Integer id) {
        return service.getOneGoods(id);
    }

    @PostMapping("/getPart")
    public Result<?> getPartGoods(@RequestBody Goods goods,
                                  @RequestParam(required = false) Integer pageNum,
                                  @RequestParam(required = false) Integer pageSize) {
        return service.getPartGoods(goods,pageNum,pageSize);
    }
}
